package paintObjects;

import interfaces.IPaintable;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.io.Serializable;

public class Circle implements IPaintable, Serializable {

	private int xPostion;
	private int yPosition;
	private int radius;
	private Color paintColor;

	public Circle(int xPostion, int yPosition, Color color) {

		this.xPostion = xPostion;
		this.yPosition = yPosition;
		this.radius = 0;
		this.paintColor = color;

	}

	@Override
	public void painting(Graphics2D g, boolean tmp) {

		if (tmp) {

			float[] dash = { 5f, 5f };

			g.setStroke(new BasicStroke(2f, BasicStroke.CAP_BUTT,
					BasicStroke.JOIN_BEVEL, 1f, dash, 0));

		} else {

			g.setStroke(new BasicStroke(2f));

		}

		g.setPaint(paintColor);
		g.drawOval(xPostion - radius, yPosition - radius, 2 * radius,
				2 * radius);

	}

	@Override
	public void update(int x, int y) {
		this.radius = (int) Math.sqrt(Math.pow(x - xPostion, 2)
				+ Math.pow(y - yPosition, 2)); // Satz des Pythagoras
	}

}
